
<style type="text/css">
    .tab-pane.active{position:relative;margin:0 15px;}
    .tab-pane.active .tabright{position:absolute;right:0;top:-43px;right:0;}
    .unline{text-decoration:line-through;color:#666;}
    .from_table .pad3{padding-left:3px;padding-right:3px;}
</style>
<link rel="stylesheet" type="text/css" href="/public/store/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="/public/store/daterangepicker-bs3.css">

<ol class="breadcrumb">
    <li class="active"><a href="#">订单详情</a></li>
</ol>
<!-- seat end -->
<div class="row">
    <!-- rightcont start -->

    <ul class="nav nav-tabs gn_tabs">
        <label style="float: left;margin-top: 3px" for="searchStr">桌台号：&nbsp</label><input style="float: left;width: calc(100% - 170px)" id="searchStr" class="form-control">
        <a href="#searchGoodList" role="presentation" class="btn btn-default" style="color:black !important;margin-left: 10px" id="search_a">
            <span  class="glyphicon glyphicon-search"></span>搜索
        </a>
        <p></p>
        <li role="presentation" class="active"><a href="#receive">已接单</a></li>
        <li role="presentation"><a href="#complete">已完成</a></li>
        <li role="presentation"><a href="#refuseList">已退单</a></li>
        <li role="presentation"><a href="#orderSearch">订单时间段查询</a></li>
    </ul>
    <div class="tab-content">
        <div url="orderReceive" role="tabpanel" class="tab-pane active" id="receive">
        </div>
        <div url="orderComplete" role="tabpanel" class="tab-pane" id="complete">
        </div>
        <div url="refuseList" role="tabpanel" class="tab-pane" id="refuseList">
        </div>
        <div url="getOrderByTime" role="tabpanel" class="tab-pane" id="orderSearch">
        </div>
    </div>
    <!-- rightcont end -->
</div>

    <!--订单列表模板-->
<script type="text/html" id="order_tmpl">

{{if status=='orderSearch'}}
    <form class="memberbox gn_tabs grid searchbox">
        <div class="shai">筛选条件：</div>
        <div class="g-col form-inline">
            <input type="text" name="startTime" class="form-control datetime" size="21" value="{{startTime}}" />
            至
            <input type="text" name="endTime" class="form-control datetime" size="21" value="{{endTime}}" />
            <span class="blue daterang hand" data-day="6">最近7天</span>
            <span class="blue daterang hand" data-day="29">最近30天</span>
            <button class="btn gn_btn search">筛选</button>
            <button class="btn gn_btn gray_btn reset">清空</button>
        </div>
    </form>
{{/if}}

{{if totalRow>0}}
    <div class="grid container-fluid fromhead middle">
        <div class="g-col list-total">
            共筛选出 <span class="red">{{totalRow}}</span> 条信息，
            小计：<span class="red">￥{{(totalSum/100).toFixed(2)}}</span>，
            总积分：<span class="red">{{if totalScore}}{{totalScore}}{{else}}0{{/if}}</span>,
            订单平均消费：<span class="red">{{((totalSum/100)/totalRow).toFixed(2)}}</span>
        </div>
    </div>
{{/if}}
{{if (appId=="wx6a5c075ce0f090da"||appId=="wxbe522a217c7da437")&&status!="orderSearch"}}
    <div class="table-instructions-container">
        <div class="table-container">
            <div class="table tableEmpty"><p>空座</p></div>
        </div>
        <div class="table-container">
            <div class="table tableReceived"><p>已接单</p></div>
        </div>
        <div class="table-container">
            <div class="table tablePaid"><p>已付款</p></div>
        </div>
            <button class="btn btn-default" style="color:black !important;float: right" id="desk_editor_control" >桌台编辑</button>
    </div>
    {{each tableList as vo i}}
        <div class="table-container">
            <div class="table
                {{if vo.orderList.length>0}}
                    {{if vo.orderList[0].orderState<20}}tableReceived
                    {{else}}tablePaid
                    {{/if}}
                {{else}}
                tableEmpty
                {{/if}}" name="table" data-table-id="{{vo.stid}}">
                <p>{{vo.stname}}</p>
                {{if vo.orderList.length>0}}
                <p>该桌有{{vo.orderList.length}}单</p>
                <p>订单时间{{vo.orderList[0].ctime2[1]}}</p>
                <p>总金额{{(vo.totalMoney/100).toFixed(2)}}</p>
                {{/if}}
            </div>
            <p name="desk_editor_p">
                <button class="btn btn-default" style="color:black !important;" data-table-id="{{vo.stid}}" name="desk_editor">编辑</button>
            </p>
        </div>
    {{/each}}
    <div class="table-container"  id="add_table">
        <div class="table tableEmpty">
            <img src="http://sfs.shuwang.info/sfcommon/1001/2017-10-28/6uY60Oreu-加号.png">
        </div>
        <p name="desk_editor_p" style="color: white;line-height: 34px">&nbsp</p>
    </div>
{{/if}}
{{if !((appId=="wx6a5c075ce0f090da"||appId=="wxbe522a217c7da437")&&status!="orderSearch")}}
    <table class="table table-bordered from_table">
        <tr>
            <th class="text-center pad3" nowrap>流水号</th>
            <th class="text-center" nowrap>订单编号</th>
            <th class="text-center pad3" nowrap >包厢号</th>
            <!-- <th class="text-center" nowrap>订单状态</th> -->
            <th class="text-center" nowrap>支付方式</th>
            <th class="text-center" nowrap>订单备注</th>
            <th class="text-center" nowrap>下单时间</th>
            <th class="text-center pad3" nowrap>总金额/积分</th>
            {{if status=='receive' || status=='complete'}}
            <th class="text-center" nowrap>操作</th>
            {{else if status=='orderSearch'}}
            <th class="text-center" nowrap>状态</th>
            {{/if}}
        </tr>
        {{each dataList as vo i}}
        <tr>
             <td class="text-center" nowrap>
            <a class="hand blue chakan" data-i="{{i}}" data-orderNo="{{vo.orderNo}}">{{vo.flowNo}}</a></td>
             <td class="text-center" nowrap>
            <a class="hand blue chakan" data-i="{{i}}" data-orderNo="{{vo.orderNo}}" >{{vo.orderNo}}</a></td>
            <td class="text-center">{{vo.roomId}}</td>
            <td class="text-center" nowrap>
            {{if vo.payType==0}}
            微信支付
            {{else if vo.payType==1}}
            会员钱包
            {{else if vo.payType==2}}
            <span class="red">积分兑换</span>
            {{else if vo.payType==3}}
            收款码
            {{else if vo.payType==4}}
            POS机收款
            {{else if vo.payType==5}}
            现金收款
            {{else if vo.payType==6}}
            支付宝收款
            {{/if}}
            </td>
            <td class="text-center">{{vo.message}}</td>
            <td class="text-center" nowrap>{{vo.ctime}}</td>
            <td class="text-center" nowrap>
            {{if vo.menuState==40}}
            {{if vo.payType==2}}{{vo.refundMoney}}{{else}}￥{{(vo.refundMoney/100).toFixed(2)}}{{/if}}
            {{else}}
            {{if vo.payType==2}}{{vo.totalMoney}}{{else}}￥{{(vo.totalMoney/100).toFixed(2)}}{{/if}}{{/if}}
            </td>
            {{if status=='receive'}}
            <td class="text-center" nowrap>
                <p class="finish hand green" data-i="{{i}}" data-orderNo="{{vo.orderNo}}">完成</p>
                <p class="print hand blue" data-i="{{i}}" data-orderNo="{{vo.orderNo}}">打印</p>
                <p class="payment hand black" data-i="{{i}}" data-orderNo="{{vo.orderNo}}">支付</p>
                <p class="addGoods hand black" data-i="{{i}}" data-orderNo="{{vo.orderNo}}">加菜/换桌</p>
                {{if vo.payType!=2}}
                <span class="red hand chakan" data-type="edit" data-i="{{i}}" data-orderNo="{{vo.orderNo}}">退单</span>
                {{/if}}
            </td>
            {{else if status=='complete'}}
            <td class="text-center" nowrap><span class="print hand blue" data-i="{{i}}" data-orderNo="{{vo.orderNo}}">打印</span></td>
            {{else if status=='orderSearch'}}
            <td class="text-center" nowrap>
                {{if vo.menuState==10}}
                <span class="green">已接单</span>
                {{else if vo.menuState==11}}
                <span class="green">待付款</span>
                {{else if vo.menuState==20}}
                <span class="gray">已完成</span>
                {{else if vo.menuState==30}}
                <span class="red">已退单</span>
                {{/if}}
            </td>
            {{/if}}
        </tr>
        {{/each}}
    </table>
{{/if}}

{{if totalPage>1}}
    <nav class="text-right">
        <ul class="pagination">
            {{if pageNumber>1}}
            <li>
                <a href="{{pageNumber-1}}" aria-label="Previous">
                    <span aria-hidden="true">上一页</span>
                </a>
            </li>
            {{/if}}
            {{for var i = pageNumber-5; i < pageNumber + 5; i++}}
            {{if i>0 && i <= totalPage}}
            <li{{if i == pageNumber}} class="active"{{/if}}><a href="{{i}}">{{i}}</a></li>
            {{/if}}
            {{/for}}
            {{if pageNumber<totalPage}}
            <li>
                <a href="{{pageNumber+1}}" aria-label="Next">
                    <span aria-hidden="true">下一页</span>
                </a>
            </li>
            {{/if}}
        </ul>
    </nav>
{{/if}}
</script>

    <!--订单列表浮窗-->
<script type="text/html" id="table_order_tmpl">
        <table class="table table-bordered from_table">
            <tr>
                <th class="text-center pad3" nowrap>流水号</th>
                <th class="text-center" nowrap>订单编号</th>
                <th class="text-center pad3" nowrap >包厢号</th>
                <!-- <th class="text-center" nowrap>订单状态</th> -->
                <th class="text-center" nowrap>支付方式</th>
                <th class="text-center" nowrap>订单备注</th>
                <th class="text-center" nowrap>下单时间</th>
                <th class="text-center pad3" nowrap>总金额/积分</th>
                <!-- <th class="text-center" nowrap>积分支付</th> -->
                <!--<th class="text-center pad3" nowrap>总收款/消费积分</th>-->
                {{if status=='receive' || status=='complete'}}
                <th class="text-center" nowrap>操作</th>
                {{/if}}
            </tr>
            {{each orderList as vo i}}
            <tr>
                <td class="text-center" nowrap>
                    <a class="hand blue chakan" data-i="{{i}}" data-orderNo="{{vo.orderNo}}">{{vo.flowNo}}</a></td>
                <td class="text-center" nowrap>
                    <a class="hand blue chakan" data-i="{{i}}" data-orderNo="{{vo.orderNo}}">{{vo.orderNo}}</a></td>
                <td class="text-center">{{vo.roomId}}</td>
                <td class="text-center" nowrap>
                    {{if vo.payType==0}}
                    微信支付
                    {{else if vo.payType==1}}
                    会员钱包
                    {{else if vo.payType==2}}
                    <span class="red">积分兑换</span>
                    {{else if vo.payType==3}}
                    收款码
                    {{else if vo.payType==4}}
                    POS机收款
                    {{else if vo.payType==5}}
                    现金收款
                    {{else if vo.payType==6}}
                    支付宝收款
                    {{/if}}
                </td>
                <td class="text-center">{{vo.message}}</td>
                <td class="text-center" nowrap>{{vo.ctime}}</td>
                <td class="text-center" nowrap>
                    {{if vo.menuState==40}}
                    {{if vo.payType==2}}{{vo.refundMoney}}{{else}}￥{{(vo.refundMoney/100).toFixed(2)}}{{/if}}
                    {{else}}
                    {{if vo.payType==2}}{{vo.totalMoney}}{{else}}￥{{(vo.totalMoney/100).toFixed(2)}}{{/if}}{{/if}}
                </td>

                {{if status=='receive'}}
                <td class="text-center" nowrap>
                    <p class="finish hand green" data-i="{{i}}" data-orderNo="{{vo.orderNo}}">完成</p>
                    <p class="print hand blue" data-i="{{i}}" data-orderNo="{{vo.orderNo}}">打印</p>
                    {{if vo.orderState<20}}
                        <p class="payment hand purple" data-i="{{i}}" data-orderNo="{{vo.orderNo}}">支付</p>
                        <p class="addGoods hand black" data-i="{{i}}" data-orderNo="{{vo.orderNo}}">加菜/换桌</p>
                    {{/if}}
                    {{if vo.payType!=2}}
                    <span class="red hand chakan" data-type="edit" data-i="{{i}}" data-orderNo="{{vo.orderNo}}">退单</span>
                    {{/if}}
                </td>
                {{else if status=='complete'}}
                <td class="text-center" nowrap><span class="print hand blue" data-i="{{i}}" data-orderNo="{{vo.orderNo}}">打印</span></td>
                {{/if}}
            </tr>
            {{/each}}
        </table>
    </script>

    <!--设置优惠浮框-->
<script type="text/html" id="discount_tmpl">
    <table class="table table-bordered from_table">
        <tr>
            <td>合计:</td>
            <td>
                <span style="margin-left:10px;position: relative;top: 2px;">普通：</span>
                <input id="totalMoney" type="number" style="width: 100px;display: inline-block" class="form-control" value="{{((commonPrice+coupon+discount)/100).toFixed(2)}}" disabled>
                <span style="margin-left:10px;position: relative;top: 2px;">元</span>
            </td>
            <td>
                <span style="margin-left:10px;position: relative;top: 2px;">会员：</span>
                <input id="memberMoney" type="number" style="width: 100px;display: inline-block" class="form-control" value="{{((memberPrice+coupon+discount)/100).toFixed(2)}}" disabled>
                <span style="margin-left:10px;position: relative;top: 2px;">元</span>
            </td>
        </tr>
        <tr>
            <td>优惠券:</td>
            <td colspan="2">
                <input id="coupon" type="number" style="width: 100px;display: inline-block" class="form-control" value="{{(coupon/100).toFixed(2)}}">
                <span style="margin-left:10px;position: relative;top: 2px;">元</span>
            </td>
        </tr>
        <tr>
            <td>抹零:</td>
            <td colspan="2">
                <input id="discount" type="number" style="width: 100px;display: inline-block" class="form-control" value="{{(discount/100).toFixed(2)}}">
                <span style="margin-left:10px;position: relative;top: 2px;">元</span>
            </td>
        </tr>
        {{if discountGoodsTypeList.length>0}}
            <tr>
                <td rowspan="{{discountGoodsTypeList.length+1}}">分类折扣:</td>
                <td>
                    全单折扣
                </td>
                <td>
                    {{each allDiscountList as vo i}}
                       {{vo}} <input type="radio" class="checkbox" name="AllDiscountLimit" value="{{vo}}">
                    {{/each}}
                    不打折<input type="radio" class="checkbox" name="AllDiscountLimit" value="10" checked="checked">
                </td>
                {{each discountGoodsTypeList as vo i}}
                    <tr>
                        <td>
                            {{vo.goodsTypeName}}
                        </td>
                        <td name="singleDiscountLimit">
                            {{for var i=0; i < vo.discountLimit.length; i++}}
                                {{vo.discountLimit[i]}}折
                            <input type="radio" class="checkbox" value="{{vo.discountLimit[i]}}"  name="{{vo.goodsTypeName}}" data-goods-type-id="{{vo.id}}">
                            {{/for}}
                            不打折
                            <input type="radio" class="checkbox" value="10"  name="{{vo.goodsTypeName}}" data-goods-type-id="{{vo.id}}" checked="checked">
                        </td>
                    </tr>
                {{/each}}
            </tr>
        {{/if}}
        <tr>
            <td>应付:</td>
            <td>
                <span style="margin-left:10px;position: relative;top: 2px;">普通：</span>
                <input id="pay" type="number" style="width: 100px;display: inline-block" class="form-control" value="{{(commonPrice/100).toFixed(2)}}" disabled>
                <span style="margin-left:10px;position: relative;top: 2px;">元</span>
            </td>
            <td>
                <span style="margin-left:10px;position: relative;top: 2px;">会员：</span>
                <input id="memberpay" type="number" style="width: 100px;display: inline-block" class="form-control" value="{{(memberPrice/100).toFixed(2)}}" disabled>
                <span style="margin-left:10px;position: relative;top: 2px;">元</span>
            </td>
        </tr>
        <tr>
            <td><button id="table" class="btn btn-default" style="color: black!important;">桌台</button></td>
            <td colspan="2">
                <span style="margin-left:10px;position: relative;top: 2px;">是否是会员</span><input type="checkbox" class="checkbox" id="isMember">
                <button id="other_payments" class="btn btn-default" style="color: black!important;margin-left: 70px">其他支付</button>
            </td>
        </tr>
    </table>
</script>

    <!--二维码浮框-->
<script type="text/html" id="QR_code_tmpl">
    <div id="QR_code" style="padding-left: 40px"></div>
</script>

    <!--退单/查看详情浮框-->
<script type="text/html" id="order_goods_tmpl">
    <table class="table table-bordered from_table">
        {{if edit}}
        <tr>
            <th colspan="2">请输入退款理由：</th>
            <th colspan="6"><input type="text" id="refundReason" style="width:100%;height:100%;border:none;outline:0"></th>
        </tr>
        {{/if}}
        <tr>
            <th class="text-center" nowrap>序号</th>
            <th class="text-center" nowrap>商品名称</th>
            <th class="text-center" nowrap>商品图片</th>
            <th class="text-center" nowrap>数量</th>
            {{if payType==2}}
            <th class="text-center" nowrap>积分</th>
            <th class="text-center" nowrap>小计</th>
            {{else}}
            <th class="text-center" nowrap>单价</th>
            <th class="text-center" nowrap>金额</th>
            {{/if}}
            {{if edit}}
            <th class="text-center" nowrap>退单数</th>
            <th class="text-center hand" nowrap><span class="checkAll">全选</span>/<span class="inverse">取消</span></th>
            {{/if}}
        </tr>
        {{each list as vo i}}
        <tr {{if vo.goodsState<1}} class="unline"{{/if}}>
            <td class="text-center">{{i+1}}</td>
            <td class="text-center">{{vo.goodsName}}</td>
            <td class="text-center"><img src="{{vo.goodsLogo}}" style="max-height:100px;" /></td>
            <td class="text-center">{{vo.goodsCount}}{{" "+vo.units}}</td>
            {{if payType==2}}
            <td class="text-center">{{vo.goodsScore}}</td>
            <td class="text-center">{{vo.goodsScore*vo.goodsCount}}</td>
            {{else}}
            <td class="text-center">
            ￥{{if vo.isMemberPrice}}{{(vo.goodsMemberPrice/100).toFixed(2)}}{{else}}{{(vo.goodsCommonPrice/100).toFixed(2)}}{{/if}}
            </td>
            <td class="text-center">
            ￥{{if vo.isMemberPrice}}{{(vo.goodsMemberPrice*vo.goodsCount/100).toFixed(2)}}{{else}}{{(vo.goodsCommonPrice*vo.goodsCount/100).toFixed(2)}}{{/if}}
            </td>
            {{/if}}
            {{if edit}}
                <td class="text-center">
                    <span name="{{vo.goodsId}}" class="glyphicon glyphicon-plus"></span>
                    <input id="{{vo.goodsId}}" type="number" class="form-control" style="width: 30%;display: inline-block" data-max="{{vo.goodsCount}}" data-units="{{vo.units}}" value="0" disabled>
                    <span name="{{vo.goodsId}}" class="glyphicon glyphicon-minus"></span>
                </td>
                <td class="text-center"><input type="checkbox" name="goodsId" value="{{vo.goodsId}}" class="checkbox" style="border:0;color:#FFF;"{{if vo.goodsState < 1}} disabled{{/if}} /></td>
            {{/if}}
        </tr>
        {{/each}}
    </table>
</script>

    <!--编辑桌台浮框-->
<script type="text/html" id="desk_editor_tmpl">
    <label for="stid">桌台ID</label><input id="stid" type="number" class="form-control" disabled value="{{stid}}">
    <label for="stname">桌台名称</label><input id="stname" class="form-control" value="{{stname}}">
</script>

    <!--引入插件js代码-->
<script src="http://cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="/public/store/moment.js"></script>
<script src="/public/store/daterangepicker.js"></script>
<!--二维码库-->
<script src="http://o2o.shuwang.info/eshopmgr/lib/jquery-qrcode-0.14.0.min.js"></script>